/**
 *   @author Giulio Rossetti <Giulio.Rossetti@gmail.com>
 *   @version 1.0 31\05\2009
 *
 *   This file is part of "HotSpot Locator".
 *
 *   "HotSpot Locator" is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   "HotSpot Locator" is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with Foobar.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

package HotSpotLocator;

import javax.microedition.location.Coordinates;
import javax.microedition.location.Criteria;
import javax.microedition.location.Location;
import javax.microedition.location.LocationException;
import javax.microedition.location.LocationProvider;

/**
 * @author Giulio Rossetti <Giulio.Rossetti@gmail.com>
 * @version 1.0 31\05\2009
 */
public class PositionFetcher extends Thread {
    
    private Coordinates position;

    public void run(){
        Criteria cr = new Criteria();
        cr.setCostAllowed(true);
        cr.setPreferredPowerConsumption(Criteria.NO_REQUIREMENT);
        LocationProvider provider;

        try {
            provider = LocationProvider.getInstance(cr);
            Location location = provider.getLocation(180);
            position = location.getQualifiedCoordinates();
        } catch (LocationException ex) {
            ex.printStackTrace();
        } catch (InterruptedException ex) {
            ex.printStackTrace();
        }

    }

    public Coordinates getPosition(){
        return this.position;
    }
}
